using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Episode02
{
    public class GunController : MonoBehaviour
    {
        public Transform weaponHold;
        public Gun startingGun;

        Gun equipedGun;

        private void Start()
        {
            if(null != startingGun)
            {
                EquipGun(startingGun);
            }
        }

        public void EquipGun(Gun gunToEquip)
        {
            if(null != equipedGun)
            {
                Destroy(equipedGun.gameObject);
            }
            equipedGun = Instantiate(gunToEquip, weaponHold.position, weaponHold.rotation) as Gun;
            equipedGun.transform.parent = weaponHold;
        }

        public void Shoot()
        {
            if(null != equipedGun)
            {
                equipedGun.Shoot();
            }
        }
    }
}